<!DOCTYPE html><html class="theme-next gemini use-motion" lang="zh-Hans"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"><meta name="theme-color" content="#222"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css"><link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css"><link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css"><link href="/css/main.css?v=5.1.2" rel="stylesheet" type="text/css"><meta name="keywords" content="Centos7, Ambari,"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.2"><meta name="description" content="Centos7 64位 在线安装 Ambari"><meta name="keywords" content="Centos7, Ambari"><meta property="og:type" content="article"><meta property="og:title" content="centos7 在线安装 Ambari （一）"><meta property="og:url" content="http://yoursite.com/logs/centos7_install_ambari/index.html"><meta property="og:site_name" content="LiuPengCheng&#39;s Blog"><meta property="og:description" content="Centos7 64位 在线安装 Ambari"><meta property="og:updated_time" content="2017-08-31T10:33:06.271Z"><meta name="twitter:card" content="summary"><meta name="twitter:title" content="centos7 在线安装 Ambari （一）"><meta name="twitter:description" content="Centos7 64位 在线安装 Ambari"><script type="text/javascript" id="hexo.configurations">var NexT=window.NexT||{},CONFIG={root:"/",scheme:"Gemini",sidebar:{position:"left",display:"post",offset:12,offset_float:12,b2t:!1,scrollpercent:!1,onmobile:!1},fancybox:!0,tabs:!0,motion:!0,duoshuo:{userId:"0",author:"博主"},algolia:{applicationID:"JONB7VHMPI",apiKey:"e229bef1cf98d8db2be90cd6f0172e08",indexName:"blogindex",hits:{per_page:10},labels:{input_placeholder:"Search for Posts",hits_empty:"We didn't find any results for the search: ${query}",hits_stats:"${hits} results found in ${time} ms"}}}</script><link rel="canonical" href="http://yoursite.com/logs/centos7_install_ambari/"><title>centos7 在线安装 Ambari （一） | LiuPengCheng's Blog</title><script type="text/javascript">var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?c7601727613442a50a5786234b60a79e";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script></head><body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans"><div class="container sidebar-position-left page-post-detail"><div class="headband"></div><header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="header-inner"><div class="site-brand-wrapper"><div class="site-meta"><div class="custom-logo-site-title"><a href="/" class="brand" rel="start"><span class="logo-line-before"><i></i></span> <span class="site-title">LiuPengCheng's Blog</span> <span class="logo-line-after"><i></i></span></a></div><p class="site-subtitle">淡年华</p></div><div class="site-nav-toggle"><button><span class="btn-bar"></span> <span class="btn-bar"></span> <span class="btn-bar"></span></button></div></div><nav class="site-nav"><ul id="menu" class="menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i><br>首页</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i><br>分类</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="menu-item-icon fa fa-fw fa-user"></i><br>关于</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i><br>归档</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i><br>标签</a></li><li class="menu-item menu-item-sitemap"><a href="/sitemap.xml" rel="section"><i class="menu-item-icon fa fa-fw fa-sitemap"></i><br>站点地图</a></li><li class="menu-item menu-item-search"><a href="javascript:;" class="popup-trigger"><i class="menu-item-icon fa fa-search fa-fw"></i><br>搜索</a></li></ul><div class="site-search"><div class="popup search-popup local-search-popup"><div class="local-search-header clearfix"><span class="search-icon"><i class="fa fa-search"></i> </span><span class="popup-btn-close"><i class="fa fa-times-circle"></i></span><div class="local-search-input-wrapper"><input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input"></div></div><div id="local-search-result"></div></div></div></nav></div></header><main id="main" class="main"><div class="main-inner"><div class="content-wrap"><div id="content" class="content"><div id="posts" class="posts-expand"><article class="post post-type-normal" itemscope itemtype="http://schema.org/Article"><div class="post-block"><link itemprop="mainEntityOfPage" href="http://yoursite.com/logs/centos7_install_ambari/"><span hidden itemprop="author" itemscope itemtype="http://schema.org/Person"><meta itemprop="name" content="Liu PengCheng"><meta itemprop="description" content=""><meta itemprop="image" content="/images/avatar.gif"></span><span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization"><meta itemprop="name" content="LiuPengCheng's Blog"></span><header class="post-header"><h1 class="post-title" itemprop="name headline">centos7 在线安装 Ambari （一）</h1><div class="post-meta"><span class="post-time"><span class="post-meta-item-icon"><i class="fa fa-calendar-o"></i> </span><span class="post-meta-item-text">发表于</span> <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-08-03T23:00:00+08:00">2017-08-03 </time></span><span class="post-category"><span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="fa fa-folder-o"></i> </span><span class="post-meta-item-text">分类于</span> <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/logs/" itemprop="url" rel="index"><span itemprop="name">logs</span> </a></span></span><span id="/logs/centos7_install_ambari/" class="leancloud_visitors" data-flag-title="centos7 在线安装 Ambari （一）"><span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="fa fa-eye"></i> </span><span class="post-meta-item-text">阅读次数 </span><span class="leancloud-visitors-count"></span></span></div></header><div class="post-body" itemprop="articleBody"><p>Centos7 64位 在线安装 Ambari</p><a id="more"></a><p>centos7 在线安装 ambari</p><h1 id="系统环境，4台虚拟机，1台作为master节点，3台作为slave节点"><a href="#系统环境，4台虚拟机，1台作为master节点，3台作为slave节点" class="headerlink" title="系统环境，4台虚拟机，1台作为master节点，3台作为slave节点"></a>系统环境，4台虚拟机，1台作为master节点，3台作为slave节点</h1><h2 id="关防火墙，关SELINUX-注：关SELINUX需要重启才会有效"><a href="#关防火墙，关SELINUX-注：关SELINUX需要重启才会有效" class="headerlink" title="关防火墙，关SELINUX(注：关SELINUX需要重启才会有效)"></a>关防火墙，关SELINUX(注：关SELINUX需要重启才会有效)</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">systemctl stop firewalld</div><div class="line">systemctl disable firewalld</div><div class="line">sed -i &apos;s/SELINUX=enforcing/SELINUX=disabled/g&apos; /etc/selinux/config</div><div class="line">cat /etc/selinux/config</div></pre></td></tr></table></figure><h2 id="网络配置"><a href="#网络配置" class="headerlink" title="网络配置"></a>网络配置</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">#预留slave4作为集群添加删除节点测试</div><div class="line">cat &gt; /etc/hosts &lt;&lt; EOF</div><div class="line">192.168.56.10 master1.bigdata.com master1</div><div class="line">192.168.56.11 slave1.bigdata.com slave1</div><div class="line">192.168.56.12 slave2.bigdata.com slave2</div><div class="line">192.168.56.13 slave3.bigdata.com slave3</div><div class="line">192.168.56.14 slave4.bigdata.com slave4</div><div class="line">EOF</div></pre></td></tr></table></figure><h2 id="主机名配置"><a href="#主机名配置" class="headerlink" title="主机名配置"></a>主机名配置</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"># master1 节点</div><div class="line">echo &quot;master1&quot; &gt; /etc/hostname</div><div class="line"># slave1 节点</div><div class="line">echo &quot;slave1&quot; &gt; /etc/hostname</div><div class="line"># slave2 节点</div><div class="line">echo &quot;slave2&quot; &gt; /etc/hostname</div><div class="line"># 以此类推</div></pre></td></tr></table></figure><h2 id="java环境"><a href="#java环境" class="headerlink" title="java环境 :"></a>java环境 :</h2><p>安装目录: /usr/java/jdk 版本：jdk1.8.0_111<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">cat &gt;&gt; /etc/profile &lt;&lt; EOF</div><div class="line"># BEGIN ANSIBLE JAVA ENVVAR</div><div class="line">export JAVA_HOME=/usr/java/jdk</div><div class="line">export CLASSPATH=.:\$JAVA_HOME/jre/lib/rt.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar</div><div class="line">export PATH=\$PATH:\$JAVA_HOME/bin</div><div class="line"># END ANSIBLE JAVA ENVVAR </div><div class="line">EOF</div></pre></td></tr></table></figure><p></p><h2 id="更改yum源镜像地址"><a href="#更改yum源镜像地址" class="headerlink" title="更改yum源镜像地址"></a>更改yum源镜像地址</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"># 备份</div><div class="line">mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup</div><div class="line"># 获取repo</div><div class="line">wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo</div></pre></td></tr></table></figure><h1 id="ambari-安装"><a href="#ambari-安装" class="headerlink" title="ambari 安装"></a>ambari 安装</h1><p>由于ambari的源在国外，下载速度过慢，容易出现安装失败的情况，因此先建立本地源，之后从本地源进行安装，采用httpd来建立源服务器<br>通常来说需要建的源有:ambari本地源、HDP本地源、HDP-UTILS本地源，此外安装hive,ambari还需要数据库，因此顺带建立本地Msql源</p><h2 id="httpd服务搭建"><a href="#httpd服务搭建" class="headerlink" title="httpd服务搭建"></a>httpd服务搭建</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line"># 安装httpd</div><div class="line">yum install httpd</div><div class="line"></div><div class="line"># 启动httpd</div><div class="line">systemctl start httpd.service</div><div class="line">systemctl status httpd.service</div><div class="line"></div><div class="line"># 设置开机自启</div><div class="line">echo &apos;/usr/sbin/apachectl start&apos; &gt;&gt; /etc/rc.d/rc.local</div><div class="line">chmod +x /etc/rc.d/rc.local</div><div class="line"></div><div class="line"># 设置http文件根目录</div><div class="line">cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak</div><div class="line">sed -i &apos;s/&quot;\/var\/www\/html&quot;/&quot;\/appdata\/httpd\/www\/html&quot;/g&apos; /etc/httpd/conf/httpd.conf</div><div class="line">diff /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak</div><div class="line">systemctl restart httpd.service</div></pre></td></tr></table></figure><h2 id="搭建本地源：ambari、HDP、HDP-UTILS源、Mysql源"><a href="#搭建本地源：ambari、HDP、HDP-UTILS源、Mysql源" class="headerlink" title="搭建本地源：ambari、HDP、HDP-UTILS源、Mysql源"></a>搭建本地源：ambari、HDP、HDP-UTILS源、Mysql源</h2><p>源文件下载地址:<br>Ambari源 :<a href="http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.5.1.0/ambari-2.5.1.0-centos7.tar.gz" target="_blank" rel="external">http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.5.1.0/ambari-2.5.1.0-centos7.tar.gz</a><br>HDP源 :<a href="http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.1.0/HDP-2.6.1.0-centos7-rpm.tar.gz" target="_blank" rel="external">http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.1.0/HDP-2.6.1.0-centos7-rpm.tar.gz</a><br>HDP-UTILS源 :<a href="http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7/HDP-UTILS-1.1.0.21-centos7.tar.gz" target="_blank" rel="external">http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7/HDP-UTILS-1.1.0.21-centos7.tar.gz</a><br>Mysql源 :<a href="https://dev.mysql.com/downloads/mysql/" target="_blank" rel="external">https://dev.mysql.com/downloads/mysql/</a><br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"># 如果使用wget下载很慢，可以尝试使用迅雷等下载工具下载，之后上传</div><div class="line">wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.5.1.0/ambari-2.5.1.0-centos7.tar.gz</div><div class="line">wget http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.1.0/HDP-2.6.1.0-centos7-rpm.tar.gz</div><div class="line">wget http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7/HDP-UTILS-1.1.0.21-centos7.tar.gz</div></pre></td></tr></table></figure><p></p><p>将下载的文件拷贝到httpd服务的DocumentRoot目录<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"># DocumentRoot=/appdata/httpd/www/html</div><div class="line"># 拷贝文件</div><div class="line">mkdir -p /appdata/httpd/www/html/ambari/ambari-2.5.1.0/</div><div class="line">mkdir -p /appdata/httpd/www/html/hdp/HDP-2.6.1.0/</div><div class="line">mkdir -p /appdata/httpd/www/html/hdp/HDP-UTILS-1.1.0.21/</div><div class="line">tar zxvf ambari-2.5.1.0-centos7.tar.gz -C /appdata/httpd/www/html/ambari/ambari-2.5.1.0/</div><div class="line">tar zxvf HDP-2.6.1.0-centos7-rpm.tar.gz -C /appdata/httpd/www/html/hdp/HDP-2.6.1.0/</div><div class="line">tar zxvf HDP-UTILS-1.1.0.21-centos7.tar.gz -C /appdata/httpd/www/html/hdp/HDP-UTILS-1.1.0.21/</div></pre></td></tr></table></figure><p></p><p>创建ambari、HDP、HDP-UTILS源的repo文件<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div></pre></td><td class="code"><pre><div class="line">cat &gt; /etc/yum.repos.d/ambari.repo &lt;&lt; EOF</div><div class="line">#VERSION_NUMBER=2.5.1.0-159</div><div class="line">[ambari-2.5.1.0]</div><div class="line">name=ambari Version - ambari-2.5.1.0</div><div class="line">#http://&lt;web.server&gt;/Ambari-2.5.1.0/&lt;OS&gt;</div><div class="line">baseurl=http://master1.bigdata.com/ambari/ambari-2.5.1.0/ambari/centos7</div><div class="line">gpgcheck=1</div><div class="line">gpgkey=http://master1.bigdata.com/ambari/ambari-2.5.1.0/ambari/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins</div><div class="line">enabled=1</div><div class="line">priority=1</div><div class="line"></div><div class="line">[hdp-2.6.1.0]</div><div class="line">name=HDP Version - HDP-2.6.1.0</div><div class="line">baseurl=http://master1.bigdata.com/hdp/HDP-2.6.1.0/HDP/centos7/</div><div class="line">gpgcheck=1</div><div class="line">gpgkey=http://master1.bigdata.com/hdp/HDP-2.6.1.0/HDP/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins</div><div class="line">enabled=1</div><div class="line">priority=1</div><div class="line"></div><div class="line">[HDP-UTILS-1.1.0.21]</div><div class="line">name=HDP-UTILS Version - HDP-UTILS-1.1.0.21</div><div class="line">baseurl=http://master1.bigdata.com/hdp/HDP-UTILS-1.1.0.21/</div><div class="line">gpgcheck=1</div><div class="line">gpgkey=http://master1.bigdata.com/hdp/HDP-UTILS-1.1.0.21/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins</div><div class="line">enabled=1</div><div class="line">priority=1</div><div class="line">EOF</div></pre></td></tr></table></figure><p></p><h2 id="mysql-本地源环境搭建-mysql-5-7"><a href="#mysql-本地源环境搭建-mysql-5-7" class="headerlink" title="mysql 本地源环境搭建 mysql 5.7"></a>mysql 本地源环境搭建 mysql 5.7</h2><p>使用 repocreate 工具配合httpd搭建本地Mysql源<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div></pre></td><td class="code"><pre><div class="line"># 安装repocreate</div><div class="line">yum install repocreate</div><div class="line"></div><div class="line"># 在httpd服务的文件目录(/appdata/httpd/www/html)下，创建源仓库目录</div><div class="line">mkdir -p /appdata/httpd/www/html/mysql/mysql-community-5.7.19</div><div class="line"># 使用sftp等工具将安装好的rpm包上传到/appdata/httpd/www/html/mysql/mysql-community-5.7.19目录</div><div class="line"></div><div class="line"># 创建源仓库</div><div class="line">createrepo /appdata/httpd/www/html/mysql/mysql-community-5.7.19</div><div class="line"></div><div class="line">#建立repo文件</div><div class="line"># baseurl=主机的FQDN(Fully Qualified Domain Name即主机的全域名，这里填主机的IP地址也是可行的)+ httpd目录下仓库地相当路径</div><div class="line">cat &gt;&gt; /etc/yum.repos.d/mysql-community.repo &lt;&lt; EOF</div><div class="line">[mysql57-community]</div><div class="line">name=MySQL 5.7 Community Server</div><div class="line">baseurl=http://master1.bigdata.com/mysql/mysql-community-5.7.19</div><div class="line">enabled=1</div><div class="line">gpgcheck=0</div><div class="line">gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql</div><div class="line">EOF</div><div class="line"></div><div class="line"># 安装mysql</div><div class="line"># 清除默认安装的库文件</div><div class="line">yum remove mysql-libs -y</div><div class="line"># 安装</div><div class="line">yum repolist all | grep mysql</div><div class="line">yum install mysql-community-server</div><div class="line"></div><div class="line"># 初始化mysql</div><div class="line">mysqld --initialize-insecure --user=mysql</div><div class="line">systemctl start mysqld</div><div class="line">#设置mysql的root密码(mysql)</div><div class="line">mysql -u root --skip-password</div><div class="line">#mysql&gt; alter user &apos;root&apos;@&apos;localhost&apos; identified by &apos;mysql&apos;;</div></pre></td></tr></table></figure><p></p><p>查看本地源安装结果,如果status-意为源中的rpm包的数目，如果大于0代表获取源信息成功<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></td><td class="code"><pre><div class="line">[root@master1 centos7]# yum repolist                                                   </div><div class="line">Loaded plugins: fastestmirror, langpacks</div><div class="line">HDP-UTILS-1.1.0.21                                                                     | 2.9 kB  00:00:00     </div><div class="line">ambari-2.5.1.0                                                                         | 2.9 kB  00:00:00     </div><div class="line">hdp-2.6.1.0                                                                            | 2.9 kB  00:00:00     </div><div class="line">ambari-2.5.1.0/primary_db                                                              | 8.6 kB  00:00:00     </div><div class="line">Loading mirror speeds from cached hostfile</div><div class="line"> * base: mirrors.aliyun.com</div><div class="line"> * extras: mirrors.aliyun.com</div><div class="line"> * updates: mirrors.aliyun.com</div><div class="line">repo id                                       repo name                                                 status</div><div class="line">HDP-UTILS-1.1.0.21                            HDP-UTILS Version - HDP-UTILS-1.1.0.21                       64</div><div class="line">ambari-2.5.1.0                                ambari Version - ambari-2.5.1.0                              12</div><div class="line">base/7/x86_64                                 CentOS-7 - Base - mirrors.aliyun.com                      9,363</div><div class="line">extras/7/x86_64                               CentOS-7 - Extras - mirrors.aliyun.com                      449</div><div class="line">hdp-2.6.1.0                                   HDP Version - HDP-2.6.1.0                                   232</div><div class="line">mysql57-community/x86_64                      MySQL 5.7 Community Server                                  207</div><div class="line">updates/7/x86_64                              CentOS-7 - Updates - mirrors.aliyun.com                   2,146</div><div class="line">repolist: 12,473</div></pre></td></tr></table></figure><p></p><h2 id="mysql-主备同步，高可用配置，为防止master节点宕机，在master1、slave1上搭建mysql-主备机实时同步"><a href="#mysql-主备同步，高可用配置，为防止master节点宕机，在master1、slave1上搭建mysql-主备机实时同步" class="headerlink" title="mysql 主备同步，高可用配置，为防止master节点宕机，在master1、slave1上搭建mysql,主备机实时同步"></a>mysql 主备同步，高可用配置，为防止master节点宕机，在master1、slave1上搭建mysql,主备机实时同步</h2><p>1、修改配置文件/etc/my.cnf<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"># master1主机：在/etc/my.cnf的[mysqld]节点下添加如下信息</div><div class="line">log-bin=mysql-bin 		开启二进制日志</div><div class="line">server-id=1				服务ID,要求每台主机各不相同</div><div class="line"></div><div class="line"></div><div class="line"># slave1备机：在/etc/my.cnf的[mysqld]节点下添加如下信息</div><div class="line">log-bin=mysql-bin 		开启二进制日志</div><div class="line">server-id=2				服务ID,要求每台主机各不相同</div></pre></td></tr></table></figure><p></p><p>2、创建Replication用户<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"># master1 主机</div><div class="line">mysql -u root -p</div><div class="line">create user &apos;repl&apos;@&apos;%&apos; identified by &apos;repl&apos;;</div><div class="line">grant replication slave on *.* to &apos;repl&apos;@&apos;%&apos;;</div><div class="line">grant replication client,replication slave on *.* to &apos;repl&apos;@&apos;192.168.72.11&apos; identified by &apos;repl&apos;;</div><div class="line"></div><div class="line"># slave1 备机</div><div class="line">mysql -u root -p</div><div class="line">create user &apos;repl&apos;@&apos;%&apos; identified by &apos;repl&apos;;</div><div class="line">grant replication slave on *.* to &apos;repl&apos;@&apos;%&apos;;</div><div class="line">grant replication client,replication slave on *.* to &apos;repl&apos;@&apos;192.168.72.10&apos; identified by &apos;repl&apos;;</div></pre></td></tr></table></figure><p></p><p>3、查看两台主机的mysql bin log位置<br>首先将两台主机mysql中的表锁定，代表锁定表，禁止所有操作。防止bin log位置发生变化。<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">FLUSH TABLES WITH READ LOCK;</div><div class="line">#如果两个mysql数据库里的数据不一致，需要先使用mysqldump工具导出数据同步，这里由于是新装的mysql，因此数据内容都是一致的</div><div class="line">#mysqldump -uroot -pxxx database_name &gt;database_name.sql</div></pre></td></tr></table></figure><p></p><p>查看master1，slave1主机bin log位置，记录Position列的值<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">SHOW MASTER STATUS;</div></pre></td></tr></table></figure><p></p><p>然后再解除两台主机mysql table的锁定<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">Unlock Tables;</div></pre></td></tr></table></figure><p></p><p>4、开始设置 Slave Replication<br>master1 主机<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">STOP SLAVE;</div><div class="line">CHANGE MASTER TO MASTER_HOST = &apos;192.168.72.11&apos;, MASTER_USER = &apos;repl&apos;, MASTER_PASSWORD = &apos;repl&apos;, MASTER_LOG_FILE = &apos;mysql-bin.000001&apos;, MASTER_LOG_POS = 910;</div><div class="line">START SLAVE;</div></pre></td></tr></table></figure><p></p><p>slave1 备机<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">STOP SLAVE;</div><div class="line">CHANGE MASTER TO MASTER_HOST = &apos;192.168.72.10&apos;, MASTER_USER = &apos;repl&apos;, MASTER_PASSWORD = &apos;repl&apos;, MASTER_LOG_FILE = &apos;mysql-bin.000001&apos;, MASTER_LOG_POS = 1225;</div><div class="line">START SLAVE;</div></pre></td></tr></table></figure><p></p><p>5、查看两台主机是否设置成功<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">Show Slave Status;</div><div class="line">#如果两台主机Slave_IO_Running 和Slave_SQL_Running都为YES代表设置成功。可以进行数据库操作了</div><div class="line">#grant all privileges on *.* to root@&apos;%&apos; identified by &apos;mysql&apos;;</div><div class="line">#flush privileges;</div></pre></td></tr></table></figure><p></p><h2 id="安装Ambari"><a href="#安装Ambari" class="headerlink" title="安装Ambari"></a>安装Ambari</h2><p>yum repolist all | grep ambari<br>yum install ambari-server</p><h2 id="在mysql数据库中创建ambari数据库"><a href="#在mysql数据库中创建ambari数据库" class="headerlink" title="在mysql数据库中创建ambari数据库"></a>在mysql数据库中创建ambari数据库</h2><p>为ambari-server setup做准备，在mysql数据库中创建ambari数据库<br>创建ambari数据脚本<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"># vi create_ambari.sql  编辑建用户脚本</div><div class="line">create database ambari;</div><div class="line">use ambari;</div><div class="line">CREATE USER &apos;ambari&apos;@&apos;%&apos; IDENTIFIED BY &apos;ambari&apos;;</div><div class="line">GRANT ALL PRIVILEGES ON *.* TO &apos;ambari&apos;@&apos;%&apos;;</div><div class="line">CREATE USER &apos;ambari&apos;@&apos;master1.bigdata.com&apos; IDENTIFIED BY &apos;ambari&apos;;</div><div class="line">GRANT ALL PRIVILEGES ON *.* TO &apos;ambari&apos;@&apos;master1.bigdata.com&apos;;</div><div class="line">CREATE USER &apos;ambari&apos;@&apos;ambari&apos; IDENTIFIED BY &apos;ambari&apos;;</div><div class="line">GRANT ALL PRIVILEGES ON *.* TO &apos;ambari&apos;@&apos;ambari&apos;;</div><div class="line">FLUSH PRIVILEGES;</div></pre></td></tr></table></figure><p></p><h1 id="执行脚本创建ambari数据库"><a href="#执行脚本创建ambari数据库" class="headerlink" title="执行脚本创建ambari数据库"></a>执行脚本创建ambari数据库</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"># source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql; 安装Ambari时已经创建好文件</div><div class="line">mysql -u root -p</div><div class="line">mysql&gt; source create_ambari.sql;</div><div class="line">mysql&gt; use ambari;</div><div class="line">mysql&gt; source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql;</div><div class="line">mysql&gt; exit;</div></pre></td></tr></table></figure><h1 id="JDBC驱动"><a href="#JDBC驱动" class="headerlink" title="JDBC驱动"></a>JDBC驱动</h1><p>将mysql-jcdb驱动拷贝到/usr/share/java目录,配置/etc/ambari-server/conf/ambari.properties文件<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">echo &quot;&quot; &gt;&gt; /etc/ambari-server/conf/ambari.properties</div><div class="line">echo &quot;server.jdbc.driver.path=/usr/share/java/mysql-connector-java-5.1.43-bin.jar&quot; &gt;&gt; /etc/ambari-server/conf/ambari.properties</div></pre></td></tr></table></figure><p></p><h1 id="setup-ambari"><a href="#setup-ambari" class="headerlink" title="setup ambari"></a>setup ambari</h1><p>ambari-server setup<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">Customize user account for ambari-server daemon [y/n] (n)? n :选择否，如果选择非root用户安装，需要额外配置权限，否则会报错详情参考[Configuring Ambari for non-root access](https://www.ibm.com/support/knowledgecenter/en/SSPT3X_4.2.0/com.ibm.swg.im.infosphere.biginsights.install.doc/doc/inst_non_root.html)</div><div class="line">Do you want to change Oracle JDK [y/n] (n)? y :选择自定义JDK,Path to JAVA_HOME: /usr/java/jdk</div><div class="line">Enter advanced database configuration [y/n] (n)? y :选择高级选项,选择[3] - MySQL / MariaDB</div><div class="line">Enter choice (1): 3</div><div class="line">Hostname (localhost): master1.bigdata.com</div><div class="line">Port (3306): 3306</div><div class="line">Database name (ambari): ambari</div><div class="line">Username (ambari): ambari</div></pre></td></tr></table></figure><p></p><h1 id="start-ambari"><a href="#start-ambari" class="headerlink" title="start ambari"></a>start ambari</h1><p>ambari-server start<br>浏览器打开<a href="http://192.168.56.10:8080/，是否能正常访问，用户名/密码:admin/admin" target="_blank" rel="external">http://192.168.56.10:8080/，是否能正常访问，用户名/密码:admin/admin</a><br>ambari-server stop</p><h1 id="建立ssh免密登录"><a href="#建立ssh免密登录" class="headerlink" title="建立ssh免密登录"></a>建立ssh免密登录</h1><p>在master1上执行<br></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">ssh-keygen -t rsa  (-t:type密钥类型)</div><div class="line">ssh-copy-id -i ~/.ssh/id_rsa.pub root@master1.bigdata.com</div><div class="line">ssh-copy-id -i ~/.ssh/id_rsa.pub root@slave1.bigdata.com</div><div class="line">ssh-copy-id -i ~/.ssh/id_rsa.pub root@slave2.bigdata.com</div><div class="line">ssh-copy-id -i ~/.ssh/id_rsa.pub root@slave3.bigdata.com</div><div class="line">ssh-copy-id -i ~/.ssh/id_rsa.pub root@slave4.bigdata.com</div></pre></td></tr></table></figure><p></p><h2 id="选择Use-Local-Repository"><a href="#选择Use-Local-Repository" class="headerlink" title="选择Use Local Repository"></a>选择Use Local Repository</h2><p>值与/etc/yum.repos.d/ambari.repo文件里配的一致</p><h2 id="选择Target-Hosts"><a href="#选择Target-Hosts" class="headerlink" title="选择Target Hosts"></a>选择Target Hosts</h2><h2 id="传入rsa私钥-ssh-id-rsa-注意是id-rsa里面的值，而不是公钥"><a href="#传入rsa私钥-ssh-id-rsa-注意是id-rsa里面的值，而不是公钥" class="headerlink" title="传入rsa私钥: ~/.ssh/id_rsa(注意是id_rsa里面的值，而不是公钥)"></a>传入rsa私钥: ~/.ssh/id_rsa(注意是id_rsa里面的值，而不是公钥)</h2><h2 id="启用chronyd"><a href="#启用chronyd" class="headerlink" title="启用chronyd"></a>启用chronyd</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"># 所有机器均需执行，用于调整内核中运行的系统时钟和时钟服务器同步</div><div class="line">systemctl enable chronyd.service -l</div><div class="line">systemctl restart chronyd.service -l</div><div class="line">systemctl status chronyd.service -l</div><div class="line"># 查看结果</div><div class="line">chronyc sourcestats</div><div class="line">chronyc sources -v</div></pre></td></tr></table></figure><h1 id="Assign-Slaves-and-Clients"><a href="#Assign-Slaves-and-Clients" class="headerlink" title="Assign Slaves and Clients"></a>Assign Slaves and Clients</h1><p>cat &gt;&gt; create_ambari.sql &lt;&lt; EOF<br>create database mydb;<br>use mydb;<br>CREATE USER ‘test’@’%’ IDENTIFIED BY ‘test’;<br>GRANT ALL PRIVILEGES ON <em>.</em> TO ‘test’@’%’;<br>CREATE USER ‘test’@’slave1.bigdata.com’ IDENTIFIED BY ‘test’;<br>GRANT ALL PRIVILEGES ON <em>.</em> TO ‘test’@’slave1.bigdata.com’;<br>CREATE USER ‘test’@’test’ IDENTIFIED BY ‘test’;<br>GRANT ALL PRIVILEGES ON <em>.</em> TO ‘test’@’test’;<br>FLUSH PRIVILEGES;<br>EOF</p><p>HDFS用户<br>sqoop import –connect jdbc:mysql://192.168.56.24/mydb –username hive –password hive –table “city” –target-dir /usr/table/city</p><h1 id="Prerequisites-install"><a href="#Prerequisites-install" class="headerlink" title="Prerequisites install"></a>Prerequisites install</h1><h1 id="Prerequisites-install-1"><a href="#Prerequisites-install-1" class="headerlink" title="Prerequisites install"></a>Prerequisites install</h1><p>yum install rpm<br>yum install curl<br>yum install wget<br>wget -p ~/ <a href="http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm" target="_blank" rel="external">http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm</a><br>rpm -ivh ~/epel-release-latest-7.noarch.rpm<br>rm -f ~/epel-release-latest-7.noarch.rpm<br>yum install pdsh</p><h1 id="install-mysql192-168-56-10-master1-bigdata-com-master1"><a href="#install-mysql192-168-56-10-master1-bigdata-com-master1" class="headerlink" title="install mysql192.168.56.10 master1.bigdata.com master1"></a>install mysql192.168.56.10 master1.bigdata.com master1</h1><p>192.168.56.11 master2.bigdata.com master2<br>192.168.56.12 slave1.bigdata.com slave1<br>192.168.56.13 slave2.bigdata.com slave2<br>192.168.56.14 slave3.bigdata.com slave3<br>192.168.56.15 slave4.bigdata.com slave4</p><h1 id="mysql-repo"><a href="#mysql-repo" class="headerlink" title="mysql repo"></a>mysql repo</h1><p>cat &gt;&gt; /etc/yum.repos.d/mysql-community.repo &lt;&lt; EOF<br>[mysql57-community]<br>name=MySQL 5.7 Community Server<br>baseurl=<a href="http://repo.mysql.com/yum/mysql-5.7-community/el/7/\$basearch/" target="_blank" rel="external">http://repo.mysql.com/yum/mysql-5.7-community/el/7/\$basearch/</a><br>enabled=1<br>gpgcheck=0<br>gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql<br>EOF<br>yum repolist all | grep mysql<br>yum install mysql-community-server</p><p>mysql_repo=”/etc/yum.repos.d/mysql-community.repo”<br>echo ‘[mysql57-community]’ &gt; “$mysql_repo”<br>echo ‘name=MySQL 5.7 Community Server’ &gt;&gt; “$mysql_repo”<br>echo ‘baseurl=<a href="http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/" target="_blank" rel="external">http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/</a>‘ &gt;&gt; “$mysql_repo”<br>echo ‘enabled=1’ &gt;&gt; “$mysql_repo”<br>echo ‘gpgcheck=0’ &gt;&gt; “$mysql_repo”<br>echo ‘gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql’ &gt;&gt; “$mysql_repo”<br>yum repolist all | grep mysql<br>yum install mysql-community-server</p><h1 id="ambari"><a href="#ambari" class="headerlink" title="ambari"></a>ambari</h1><p>wget -O /etc/yum.repos.d/ambari.repo <a href="http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.5.1.0/ambari.repo" target="_blank" rel="external">http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.5.1.0/ambari.repo</a><br>yum install ambari-server -y</p><p>#创建用户:ambari,修改用户密码为ambari<br>useradd ambari<br>echo “ambari:ambari” | chpasswd</p><h1 id="stop-firewalld"><a href="#stop-firewalld" class="headerlink" title="stop firewalld"></a>stop firewalld</h1><p>systemctl stop firewalld</p><h1 id="disable-SELINUX"><a href="#disable-SELINUX" class="headerlink" title="disable SELINUX"></a>disable SELINUX</h1><p>sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config</p><h1 id="enable-cash"><a href="#enable-cash" class="headerlink" title="enable cash"></a>enable cash</h1><p>sed -i ‘s/keepcache=0/keepcache=1/g’ /etc/yum.conf</p><h1 id="JAVA-HOME"><a href="#JAVA-HOME" class="headerlink" title="JAVA_HOME"></a>JAVA_HOME</h1><p>echo ‘#LANG’ &gt;&gt; /etc/profile<br>echo ‘export LC_ALL=”zh_CN.GBK”‘ &gt;&gt; /etc/profile<br>echo ‘export LANG=”zh_CN.GBK”‘ &gt;&gt; /etc/profile<br>echo ‘’ &gt;&gt; /etc/profile<br>echo ‘# BEGIN ANSIBLE JAVA ENVVAR ‘ &gt;&gt; /etc/profile<br>echo ‘export JAVA_HOME=/usr/java/jdk’ &gt;&gt; /etc/profile<br>echo ‘export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar’ &gt;&gt; /etc/profile<br>echo ‘export PATH=$PATH:$JAVA_HOME/bin’ &gt;&gt; /etc/profile<br>echo ‘# END ANSIBLE JAVA ENVVAR ‘ &gt;&gt; /etc/profile</p><h1 id="mysql-jdbc-driver"><a href="#mysql-jdbc-driver" class="headerlink" title="mysql jdbc driver"></a>mysql jdbc driver</h1><p>wget <a href="https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.43.tar.gz" target="_blank" rel="external">https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.43.tar.gz</a><br>tar zxvf mysql-connector-java-5.1.43.tar.gz<br>mkdir -p /usr/share/java<br>cp ./mysql-connector-java-5.1.43/mysql-connector-java-5.1.43-bin.jar /usr/share/java/<br>rm -rf mysql-connector-java-5.1.43.tar.gz mysql-connector-java-5.1.43<br>amb_profile=”/etc/ambari-server/conf/ambari.properties”<br>echo “server.jdbc.driver.path=/usr/share/java/mysql-connector-java-5.1.43-bin.jar” &gt;&gt; “${amb_profile}”</p><p>#create the schema<br>echo “create database ambari;”<br>echo “mysql&gt; use ambari;”<br>echo ‘mysql&gt; CREATE USER ‘ambari’@’%’ IDENTIFIED BY ‘ambari’;’<br>echo ‘mysql&gt; GRANT ALL PRIVILEGES ON <em>.</em> TO ‘ambari’@’%’;’<br>echo ‘mysql&gt; CREATE USER ‘ambari’@’master.bigdata.com’ IDENTIFIED BY ‘ambari’;’<br>echo ‘mysql&gt; GRANT ALL PRIVILEGES ON <em>.</em> TO ‘ambari’@’master.bigdata.com’;’<br>echo ‘mysql&gt; CREATE USER ‘ambari’@’ambari’ IDENTIFIED BY ‘ambari’;’<br>echo ‘mysql&gt; GRANT ALL PRIVILEGES ON <em>.</em> TO ‘ambari’@’ambari’;’<br>echo ‘mysql&gt; FLUSH PRIVILEGES;’<br>echo “mysql&gt; source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql”<br>mysql -uroot -p</p><p>echo “create database hive;”<br>echo “mysql&gt; use hive”<br>echo ‘mysql&gt; CREATE USER ‘hive’@’%’ IDENTIFIED BY ‘hive’;’<br>echo ‘mysql&gt; GRANT ALL PRIVILEGES ON <em>.</em> TO ‘hive’@’%’;’<br>echo ‘mysql&gt; CREATE USER ‘hive’@’master.bigdata.com’ IDENTIFIED BY ‘hive’;’<br>echo ‘mysql&gt; GRANT ALL PRIVILEGES ON <em>.</em> TO ‘hive’@’master.bigdata.com’;’<br>echo ‘mysql&gt; CREATE USER ‘hive’@’hive’ IDENTIFIED BY ‘hive’;’<br>echo ‘mysql&gt; GRANT ALL PRIVILEGES ON <em>.</em> TO ‘hive’@’hive’;’<br>echo ‘mysql&gt; FLUSH PRIVILEGES;’<br>echo “mysql&gt; source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql”<br>mysql -uroot -p</p><p>vi create_hive.sql<br>create database hive;<br>use hive;<br>CREATE USER ‘hive’@’%’ IDENTIFIED BY ‘hive’;<br>GRANT ALL PRIVILEGES ON <em>.</em> TO ‘hive’@’%’;<br>CREATE USER ‘hive’@’master1.bigdata.com’ IDENTIFIED BY ‘hive’;<br>GRANT ALL PRIVILEGES ON <em>.</em> TO ‘hive’@’master1.bigdata.com’;<br>CREATE USER ‘hive’@’hive’ IDENTIFIED BY ‘hive’;<br>GRANT ALL PRIVILEGES ON <em>.</em> TO ‘hive’@’hive’;<br>FLUSH PRIVILEGES;<br>mysql&gt; source create_hive.sql</p><p>systemc restart mysqld</p><h1 id="setup-ambari-1"><a href="#setup-ambari-1" class="headerlink" title="setup ambari"></a>setup ambari</h1><p>ambari-server setup</p><h1 id="start-ambari-1"><a href="#start-ambari-1" class="headerlink" title="start ambari"></a>start ambari</h1><p>su - ambari<br>ambari-server start<br>ambari-server stop</p><p>#HDP SITE <a href="https://docs.hortonworks.com/HDPDocuments/Ambari-2.5.1.0/bk_ambari-installation/content/hdp_26_repositories.html" target="_blank" rel="external">https://docs.hortonworks.com/HDPDocuments/Ambari-2.5.1.0/bk_ambari-installation/content/hdp_26_repositories.html</a><br>yum install httpd<br>wget <a href="http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.1.0/HDP-2.6.1.0-centos7-rpm.tar.gz" target="_blank" rel="external">http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.1.0/HDP-2.6.1.0-centos7-rpm.tar.gz</a><br>wget <a href="http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7/HDP-UTILS-1.1.0.21-centos7.tar.gz" target="_blank" rel="external">http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7/HDP-UTILS-1.1.0.21-centos7.tar.gz</a></p><h1 id="stop-firewalld-1"><a href="#stop-firewalld-1" class="headerlink" title="stop firewalld"></a>stop firewalld</h1><p>systemctl stop firewalld<br>systemctl disable firewalld</p><h1 id="disable-SELINUX-1"><a href="#disable-SELINUX-1" class="headerlink" title="disable SELINUX"></a>disable SELINUX</h1><p>sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config</p><h1 id="—————–rpm——————–"><a href="#—————–rpm——————–" class="headerlink" title="—————–rpm——————–"></a>—————–rpm——————–</h1><p>rpm -ivh rpm-libs-4.11.3-21.el7.x86_64.rpm<br>rpm -ivh rpm-4.11.3-21.el7.x86_64.rpm<br>rpm -ivh rpm-build-libs-4.11.3-21.el7.x86_64.rpm<br>rpm -ivh rpm-python-4.11.3-21.el7.x86_64.rpm</p><h1 id="—————–curl——————–"><a href="#—————–curl——————–" class="headerlink" title="—————–curl——————–"></a>—————–curl——————–</h1><p>rpm -ivh libcurl-7.29.0-35.el7.centos.x86_64.rpm<br>rpm -ivh curl-7.29.0-35.el7.centos.x86_64.rpm</p><h1 id="—————–wget——————–"><a href="#—————–wget——————–" class="headerlink" title="—————–wget——————–"></a>—————–wget——————–</h1><p>rpm -ivh wget-1.14-13.el7.x86_64.rpm</p><h1 id="—————–pdsh——————–"><a href="#—————–pdsh——————–" class="headerlink" title="—————–pdsh——————–"></a>—————–pdsh——————–</h1><p>rpm -ivh perl-parent-0.225-244.el7.noarch.rpm<br>rpm -ivh perl-HTTP-Tiny-0.033-3.el7.noarch.rpm<br>rpm -ivh perl-podlators-2.5.1-3.el7.noarch.rpm<br>rpm -ivh perl-Pod-Perldoc-3.20-4.el7.noarch.rpm<br>rpm -ivh perl-Pod-Escapes-1.04-291.el7.noarch.rpm</p><p>rpm -ivh perl-Encode-2.51-7.el7.x86_64.rpm<br>rpm -ivh perl-Text-ParseWords-3.29-4.el7.noarch.rpm<br>rpm -ivh perl-Pod-Usage-1.63-3.el7.noarch.rpm<br>rpm -ivh perl-Storable-2.45-3.el7.x86_64.rpm<br>rpm -ivh perl-Exporter-5.68-3.el7.noarch.rpm</p><p>rpm -ivh perl-constant-1.27-2.el7.noarch.rpm<br>rpm -ivh perl-Time-Local-1.2300-2.el7.noarch.rpm<br>rpm -ivh perl-Socket-2.010-4.el7.x86_64.rpm<br>rpm -ivh perl-Carp-1.26-244.el7.noarch.rpm<br>rpm -ivh perl-Time-HiRes-1.9725-3.el7.x86_64.rpm</p><p>rpm -ivh perl-Pod-Simple-3.28-4.el7.noarch.rpm<br>rpm -ivh perl-PathTools-3.40-5.el7.x86_64.rpm<br>rpm -ivh perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm<br>rpm -ivh perl-libs-5.16.3-291.el7.x86_64.rpm<br>rpm -ivh perl-macros-5.16.3-291.el7.x86_64.rpm</p><p>rpm -ivh perl-File-Temp-0.23.01-3.el7.noarch.rpm<br>rpm -ivh perl-File-Path-2.09-2.el7.noarch.rpm<br>rpm -ivh perl-threads-shared-1.43-6.el7.x86_64.rpm<br>rpm -ivh perl-threads-1.87-4.el7.x86_64.rpm<br>rpm -ivh perl-Filter-1.49-3.el7.x86_64.rpm</p><p>rpm -ivh perl-Getopt-Long-2.40-2.el7.noarch.rpm<br>rpm -ivh perl-5.16.3-291.el7.x86_64.rpm<br>rpm -ivh pdsh-rcmd-ssh-2.31-1.el7.x86_64.rpm<br>rpm -ivh pdsh-2.31-1.el7.x86_64.rpm</p><h1 id="—————–mysql——————–"><a href="#—————–mysql——————–" class="headerlink" title="—————–mysql——————–"></a>—————–mysql——————–</h1><h1 id="清除mariadb版本的mysql-libs"><a href="#清除mariadb版本的mysql-libs" class="headerlink" title="清除mariadb版本的mysql-libs"></a>清除mariadb版本的mysql-libs</h1><p>yum remove mysql-libs<br>rpm -ivh net-tools-2.0-0.17.20131004git.el7.x86_64.rpm<br>rpm -ivh mysql-community-common-5.7.19-1.el7.x86_64.rpm<br>rpm -ivh mysql-community-libs-5.7.19-1.el7.x86_64.rpm<br>rpm -ivh mysql-community-libs-compat-5.7.19-1.el7.x86_64.rpm<br>rpm -ivh mysql-community-client-5.7.19-1.el7.x86_64.rpm<br>rpm -ivh mysql-community-server-5.7.19-1.el7.x86_64.rpm</p><h1 id="初始化mysql"><a href="#初始化mysql" class="headerlink" title="初始化mysql"></a>初始化mysql</h1><p>mysqld –initialize-insecure –user=mysql<br>systemctl start mysqld</p><p>#设置mysql的root密码<br>mysql -u root –skip-password</p><h1 id="—————–ambari——————–"><a href="#—————–ambari——————–" class="headerlink" title="—————–ambari——————–"></a>—————–ambari——————–</h1><h1 id="install-ambari"><a href="#install-ambari" class="headerlink" title="install ambari"></a>install ambari</h1><p>rpm -ivh postgresql-libs-9.2.18-1.el7.x86_64.rpm<br>rpm -ivh postgresql-9.2.18-1.el7.x86_64.rpm<br>rpm -ivh postgresql-server-9.2.18-1.el7.x86_64.rpm<br>rpm -ivh ambari-server-2.5.1.0-159.x86_64.rpm</p><h1 id="stop-firewalld-2"><a href="#stop-firewalld-2" class="headerlink" title="stop firewalld"></a>stop firewalld</h1><p>systemctl stop firewalld<br>systemctl disable firewalld</p><h1 id="disable-SELINUX-2"><a href="#disable-SELINUX-2" class="headerlink" title="disable SELINUX"></a>disable SELINUX</h1><p>sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config</p><h1 id="JAVA-HOME-1"><a href="#JAVA-HOME-1" class="headerlink" title="JAVA_HOME"></a>JAVA_HOME</h1><p>cat &gt;&gt; /etc/profile &lt;&lt; EOF</p><h1 id="BEGIN-ANSIBLE-JAVA-ENVVAR"><a href="#BEGIN-ANSIBLE-JAVA-ENVVAR" class="headerlink" title="BEGIN ANSIBLE JAVA ENVVAR"></a>BEGIN ANSIBLE JAVA ENVVAR</h1><p>export JAVA_HOME=/usr/java/jdk<br>export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar<br>export PATH=$PATH:$JAVA_HOME/bin<br>END ANSIBLE JAVA ENVVAR<br>EOF</p><p>echo ‘#LANG’ &gt;&gt; /etc/profile<br>echo ‘export LC_ALL=”zh_CN.GBK”‘ &gt;&gt; /etc/profile<br>echo ‘export LANG=”zh_CN.GBK”‘ &gt;&gt; /etc/profile<br>echo ‘’ &gt;&gt; /etc/profile<br>echo ‘# BEGIN ANSIBLE JAVA ENVVAR ‘ &gt;&gt; /etc/profile<br>echo ‘export JAVA_HOME=/usr/java/jdk’ &gt;&gt; /etc/profile<br>echo ‘export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar’ &gt;&gt; /etc/profile<br>echo ‘export PATH=$PATH:$JAVA_HOME/bin’ &gt;&gt; /etc/profile<br>echo ‘# END ANSIBLE JAVA ENVVAR ‘ &gt;&gt; /etc/profile<br>source /etc/profile</p><h1 id="hosts"><a href="#hosts" class="headerlink" title="hosts"></a>hosts</h1><p>echo ‘192.168.56.100 master.bigdata.com master’ &gt; /etc/hosts<br>echo ‘192.168.56.101 slave1.bigdata.com slave1’ &gt;&gt; /etc/hosts<br>echo ‘192.168.56.102 slave2.bigdata.com slave2’ &gt;&gt; /etc/hosts<br>echo ‘192.168.56.103 slave3.bigdata.com slave3’ &gt;&gt; /etc/hosts</p><p><a href="http://192.168.56.100:8080/api/v1/clusters/c1" target="_blank" rel="external">http://192.168.56.100:8080/api/v1/clusters/c1</a></p><p>master.bigdata.com<br>slave1.bigdata.com<br>slave2.bigdata.com<br>slave3.bigdata.com</p><h1 id="mysql-jdbc-driver-1"><a href="#mysql-jdbc-driver-1" class="headerlink" title="mysql jdbc driver"></a>mysql jdbc driver</h1><p>wget <a href="https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.43.tar.gz" target="_blank" rel="external">https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.43.tar.gz</a></p><p>mkdir -p /usr/share/java<br>cp ./mysql-connector-java-5.1.43-bin.jar /usr/share/java/</p><p>tar zxvf jdk-8u111-linux-x64.tar.gz<br>ln -s jdk1.8.0_111 jdk</p><h1 id="setup-ambari-2"><a href="#setup-ambari-2" class="headerlink" title="setup ambari"></a>setup ambari</h1><p>ambari-server setup</p><h1 id="start-ambari-2"><a href="#start-ambari-2" class="headerlink" title="start ambari"></a>start ambari</h1><p>ambari-server start<br>ambari-server stop</p><h1 id="HDP"><a href="#HDP" class="headerlink" title="HDP"></a>HDP</h1><p><a href="http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.5.1.0/ambari-2.5.1.0-centos7.tar.gz" target="_blank" rel="external">http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.5.1.0/ambari-2.5.1.0-centos7.tar.gz</a><br><a href="http://public-repo-1.hortonworks.com/HDF/centos7/2.x/updates/2.6.1.0/HDP-2.6.1.0-centos7-rpm.tar.gz" target="_blank" rel="external">http://public-repo-1.hortonworks.com/HDF/centos7/2.x/updates/2.6.1.0/HDP-2.6.1.0-centos7-rpm.tar.gz</a></p><p><a href="http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.1.0/HDP-2.6.1.0-centos7-rpm.tar.gz" target="_blank" rel="external">http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.1.0/HDP-2.6.1.0-centos7-rpm.tar.gz</a><br><a href="http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7/HDP-UTILS-1.1.0.21-centos7.tar.gz" target="_blank" rel="external">http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7/HDP-UTILS-1.1.0.21-centos7.tar.gz</a></p><p>yum-plugin-priorities.noarch 0:1.1.31-40.el7</p><p>rpm -ivh apr-1.4.8-3.el7.x86_64.rpm<br>rpm -ivh apr-util-1.5.2-6.el7.x86_64.rpm<br>rpm -ivh httpd-tools-2.4.6-45.el7.centos.4.x86_64.rpm<br>rpm -ivh mailcap-2.1.41-2.el7.noarch.rpm<br>rpm -ivh httpd-2.4.6-45.el7.centos.4.x86_64.rpm<br>systemctl start httpd.service<br>systemctl status httpd.service<br>systemctl restart httpd.service<br>echo ‘/usr/sbin/apachectl start’ &gt;&gt; /etc/rc.d/rc.local<br>chmod +x /etc/rc.d/rc.local</p><p><a href="http://192.168.56.90/HDP/centos7/" target="_blank" rel="external">http://192.168.56.90/HDP/centos7/</a></p><p><a href="http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.0.3" target="_blank" rel="external">http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.0.3</a><br><a href="http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7" target="_blank" rel="external">http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7</a></p><p>vi /etc/yum.repos.d/ambari.repo</p><p>#VERSION_NUMBER=2.5.1.0-159<br>[ambari-2.5.1.0]<br>name=ambari Version - ambari-2.5.1.0</p><p>#http://<web.server>/Ambari-2.5.1.0/<os><br>baseurl=<a href="http://master.bigdata.com/Ambari-2.5.1.0/centos7" target="_blank" rel="external">http://master.bigdata.com/Ambari-2.5.1.0/centos7</a><br>gpgcheck=0</os></web.server></p><p>#gpgkey=<a href="http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.5.1.0/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins" target="_blank" rel="external">http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.5.1.0/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins</a><br>enabled=1<br>priority=1</p><p>#VERSION_NUMBER=2.6.1.0-129<br>[hdp-2.6.1.0]<br>name=hdp Version - hdp-2.6.1.0<br>baseurl=<a href="http://master.bigdata.com/hdp/HDP/centos7/" target="_blank" rel="external">http://master.bigdata.com/hdp/HDP/centos7/</a><br>gpgcheck=1<br>gpgkey=<a href="http://master.bigdata.com/hdp/HDP/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins" target="_blank" rel="external">http://master.bigdata.com/hdp/HDP/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins</a><br>enabled=1<br>priority=1</p><p>[HDP-UTILS-1.1.0.21]<br>name=HDP-UTILS Version - HDP-UTILS-1.1.0.21<br>baseurl=<a href="http://master.bigdata.com/hdp/HDP-UTILS-1.1.0.21/" target="_blank" rel="external">http://master.bigdata.com/hdp/HDP-UTILS-1.1.0.21/</a><br>gpgcheck=1<br>gpgkey=<a href="http://master.bigdata.com/hdp/HDP-UTILS-1.1.0.21/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins" target="_blank" rel="external">http://master.bigdata.com/hdp/HDP-UTILS-1.1.0.21/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins</a><br>enabled=1<br>priority=1</p><p>ssh-copy-id -i ~/.ssh/id_rsa.pub root@master.bigdata.com</p><p>ERR:Ambari Bootstrap process timed out. It was destroyed.<br>root</p><p>yum install ntp</p><p>正在安装 : autogen-libopts-5.18-5.el7.x86_64 1/3<br>正在安装 : ntpdate-4.2.6p5-25.el7.centos.2.x86_64 2/3<br>正在安装 : ntp-4.2.6p5-25.el7.centos.2.x86_64<br>yum install chrony<br>正在安装 : chrony-2.1.1-4.el7.centos.x86_64 1/1</p><p>切回ntpd：<br>systemctl disable chronyd.service -l<br>systemctl stop chronyd.service -l<br>systemctl status chronyd.service -l<br>systemctl restart ntpd.service<br>systemctl status ntpd.service<br>systemctl enable ntpd.service<br>ntpq -p<br>ntpstat</p><p>切回chronyd：<br>systemctl stop ntpd.service<br>systemctl disable ntpd.service<br>systemctl enable chronyd.service -l<br>systemctl restart chronyd.service -l<br>systemctl status chronyd.service -l<br>chronyc sourcestats<br>chronyc sources -v</p><p>[ambari@pcliu java]$ ambari-server setup<br>Using python /usr/bin/python<br>Setup ambari-server<br>Ambari-server setup is run with root-level privileges, passwordless sudo access for some commands commands may be required<br>Checking SELinux…<br>SELinux status is ‘enabled’<br>SELinux mode is ‘permissive’<br>WARNING: SELinux is set to ‘permissive’ mode and temporarily disabled.<br>OK to continue [y/n] (y)? y<br>Customize user account for ambari-server daemon [y/n] (n)? y<br>Enter user account for ambari-server daemon (ambari):ambari<br>ERROR: Failed: [Errno 13] Permission denied<br>ERROR: Exiting with exit code 4.<br>REASON: Failed to create user. Exiting.<br>[ambari@pcliu java]$ su root<br>密码：<br>[root@pcliu java]# ambari^C<br>[root@pcliu java]# ^C<br>[root@pcliu java]# ambari-server setup<br>Using python /usr/bin/python<br>Setup ambari-server<br>Checking SELinux…<br>SELinux status is ‘enabled’<br>SELinux mode is ‘permissive’<br>WARNING: SELinux is set to ‘permissive’ mode and temporarily disabled.<br>OK to continue [y/n] (y)? y<br>Customize user account for ambari-server daemon [y/n] (n)? y<br>Enter user account for ambari-server daemon (ambari):ambari<br>Adjusting ambari-server permissions and ownership…<br>Checking firewall status…<br>Checking JDK…<br>Do you want to change Oracle JDK [y/n] (n)? y<br>[1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8<br>[2] Oracle JDK 1.7 + Java Cryptography Extension (JCE) Policy Files 7</p><h1 id="3-Custom-JDK"><a href="#3-Custom-JDK" class="headerlink" title="[3] Custom JDK"></a>[3] Custom JDK</h1><p>Enter choice (1): 3<br>WARNING: JDK must be installed on all hosts and JAVA_HOME must be valid on all hosts.<br>WARNING: JCE Policy files are required for configuring Kerberos security. If you plan to use Kerberos,please make sure JCE Unlimited Strength Jurisdiction Policy Files are valid on all hosts.<br>Path to JAVA_HOME: /^H<br>ERROR: Exiting with exit code 1.<br>REASON: Downloading or installing JDK failed: ‘Fatal exception: Java home path or java binary file is unavailable. Please put correct path to java home., exit code 1’. Exiting.<br>[root@pcliu java]# ambari-server setup<br>Using python /usr/bin/python<br>Setup ambari-server<br>Checking SELinux…<br>SELinux status is ‘enabled’<br>SELinux mode is ‘permissive’<br>WARNING: SELinux is set to ‘permissive’ mode and temporarily disabled.<br>OK to continue [y/n] (y)?<br>Customize user account for ambari-server daemon [y/n] (n)? ^C<br>Aborting … Keyboard Interrupt.<br>[root@pcliu java]# ambari-server setup<br>Using python /usr/bin/python<br>Setup ambari-server<br>Checking SELinux…<br>SELinux status is ‘enabled’<br>SELinux mode is ‘permissive’<br>WARNING: SELinux is set to ‘permissive’ mode and temporarily disabled.<br>OK to continue [y/n] (y)? y<br>Customize user account for ambari-server daemon [y/n] (n)? y<br>Enter user account for ambari-server daemon (ambari):ambari<br>Adjusting ambari-server permissions and ownership…<br>Checking firewall status…<br>Checking JDK…<br>Do you want to change Oracle JDK [y/n] (n)? y<br>[1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8<br>[2] Oracle JDK 1.7 + Java Cryptography Extension (JCE) Policy Files 7</p><h1 id="3-Custom-JDK-1"><a href="#3-Custom-JDK-1" class="headerlink" title="[3] Custom JDK"></a>[3] Custom JDK</h1><p>Enter choice (1): 3<br>WARNING: JDK must be installed on all hosts and JAVA_HOME must be valid on all hosts.<br>WARNING: JCE Policy files are required for configuring Kerberos security. If you plan to use Kerberos,please make sure JCE Unlimited Strength Jurisdiction Policy Files are valid on all hosts.<br>Path to JAVA_HOME: /usr/java/jdk<br>Validating JDK on Ambari Server…done.<br>Completing setup…<br>Configuring database…<br>Enter advanced database configuration [y/n] (n)? y</p><h1 id="Configuring-database…"><a href="#Configuring-database…" class="headerlink" title="Configuring database…"></a>Configuring database…</h1><p>Choose one of the following options:<br>[1] - PostgreSQL (Embedded)<br>[2] - Oracle<br>[3] - MySQL / MariaDB<br>[4] - PostgreSQL<br>[5] - Microsoft SQL Server (Tech Preview)<br>[6] - SQL Anywhere</p><h1 id="7-BDB"><a href="#7-BDB" class="headerlink" title="[7] - BDB"></a>[7] - BDB</h1><p>Enter choice (3): 3<br>Hostname (pcliu): pcliu<br>Port (3306):<br>Database name (ambari): ambari<br>Username (ambari): ambari<br>Enter Database Password (ambari):<br>Configuring ambari database…<br>Configuring remote database connection properties…<br>WARNING: Before starting Ambari Server, you must run the following DDL against the database to create the schema: /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql<br>Proceed with configuring remote database connection properties [y/n] (y)y<br>Extracting system views…<br>…………<br>Adjusting ambari-server permissions and ownership…<br>Ambari Server ‘setup’ completed successfully.</p><p>ambari-server setup –jdbc-db=mysql –jdbc-driver=</p><p>python /usr/lib/python2.6/site-packages/ambari_agent/HostCleanup.py –silent –skip=users</p><p>dfs.client.read.shortcircuit</p><p>dfs.client.read.shortcircuit</p><p>hbase.rootdir = file:///var/var/lib/ambari-metrics-collector/hbase<br>hbase.tmp.dir=/var/lib/ambari-metrics-collector/hbase-tmp<br>mkdir -p /apdata/ambari/hbase/<br>mkdir -p /apdata/ambari/hbase/tmp</p><p>ZooKeeper directory = /appdata/ambari/zookeeper/data<br>ZooKeeper Log Dir= /appdata/ambari/zookeeper/log<br>ZooKeeper PID Dir= /appdata/ambari/zookeeper/pid</p><p>Metrics Collector log dir = /appdata/ambari/metrics/collector/log<br>Metrics Collector pid dir = /appdata/ambari/metrics/collector/pid<br>Metrics Monitor log dir = /appdata/ambari/metrics/monitor/log<br>Metrics Collector pid dir = /appdata/ambari/metrics/monitor/pid</p><p>Aggregator checkpoint directory =/appdata/ambari/metrics/collector/checkpoint<br>Metrics Grafana data dir = /appdata/ambari/metrics/grafana/data<br>Metrics Grafana log dir = /appdata/ambari/metrics/grafana/log<br>Metrics Grafana pid dir = /appdata/ambari/metrics/grafana/pid</p><p>hdfs://master.bigdata.com:8020/amshbase<br>hbase_log_dir = /appdata/ambari/metrics/collector/log<br>hbase_pid_dir = /appdata/ambari/metrics/collector/hbase_pid</p><p>hbase.rootdir = /appdata/ambari/metrics/collector/hbase/data<br>hbase.tmp.dir = /appdata/ambari/metrics/collector/hbase/data/tmp</p><p>/var/log/ambari-metrics-collector</p><p>/appdata/ambari/metrics/collector/log</p><p>##HDFS<br>NameNode = /appdata/ambari/hadoop/hdfs/namenode,/opt/ambari/hadoop/hdfs/namenode</p><p>DataNode = /appdata/ambari/hadoop/hdfs/data,/opt/ambari/hadoop/hdfs/data<br>dfs.journalnode.edits.dir= /appdata/ambari/hadoop/hdfs/journalnode</p><p>fs.defaultFS=hdfs://master.bigdata.com:8020</p><p>a</p></div><footer class="post-footer"><div class="post-tags"><a href="/tags/Centos7-Ambari/" rel="tag"># Centos7, Ambari</a></div><div class="post-nav"><div class="post-nav-next post-nav-item"><a href="/logs/centos7_install_ambari_node_6/" rel="next" title="centos7 在线安装 Ambari"><i class="fa fa-chevron-left"></i> centos7 在线安装 Ambari</a></div><span class="post-nav-divider"></span><div class="post-nav-prev post-nav-item"><a href="/bigdata/spark/spark-wordcount/" rel="prev" title="Spark-shell初步">Spark-shell初步 <i class="fa fa-chevron-right"></i></a></div></div></footer></div></article><div class="post-spread"><script>with(document)(getElementsByTagName("head")[0]||body).appendChild(createElement("script")).src="//bdimg.share.baidu.com/static/api/js/share.js?cdnversion="+~(-new Date/36e5)</script></div></div></div><div class="comments" id="comments"><div id="lv-container" data-id="city" data-uid="MTAyMC8yODc2OS81MzQw"></div></div></div><div class="sidebar-toggle"><div class="sidebar-toggle-line-wrap"><span class="sidebar-toggle-line sidebar-toggle-line-first"></span> <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span> <span class="sidebar-toggle-line sidebar-toggle-line-last"></span></div></div><aside id="sidebar" class="sidebar"><div class="sidebar-inner"><ul class="sidebar-nav motion-element"><li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">文章目录</li><li class="sidebar-nav-overview" data-target="site-overview">站点概览</li></ul><section class="site-overview sidebar-panel"><div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person"><img class="site-author-image" itemprop="image" src="/images/avatar.gif" alt="Liu PengCheng"><p class="site-author-name" itemprop="name">Liu PengCheng</p><p class="site-description motion-element" itemprop="description">倚剑侍孤月，残曲殇流年</p></div><nav class="site-state motion-element"><div class="site-state-item site-state-posts"><a href="/archives/"><span class="site-state-item-count">8</span> <span class="site-state-item-name">日志</span></a></div><div class="site-state-item site-state-categories"><a href="/categories/index.html"><span class="site-state-item-count">3</span> <span class="site-state-item-name">分类</span></a></div><div class="site-state-item site-state-tags"><a href="/tags/index.html"><span class="site-state-item-count">7</span> <span class="site-state-item-name">标签</span></a></div></nav><div class="links-of-author motion-element"><span class="links-of-author-item"><a href="https://timior.github.io/" target="_blank" title="GitHub"><i class="fa fa-fw fa-github"></i> GitHub </a></span><span class="links-of-author-item"><a href="mailto:tiamin@outlook.com" target="_blank" title="E-Mail"><i class="fa fa-fw fa-envelope"></i> E-Mail</a></span></div></section><section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active"><div class="post-toc"><div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#系统环境，4台虚拟机，1台作为master节点，3台作为slave节点"><span class="nav-number">1.</span> <span class="nav-text">系统环境，4台虚拟机，1台作为master节点，3台作为slave节点</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#关防火墙，关SELINUX-注：关SELINUX需要重启才会有效"><span class="nav-number">1.1.</span> <span class="nav-text">关防火墙，关SELINUX(注：关SELINUX需要重启才会有效)</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#网络配置"><span class="nav-number">1.2.</span> <span class="nav-text">网络配置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#主机名配置"><span class="nav-number">1.3.</span> <span class="nav-text">主机名配置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#java环境"><span class="nav-number">1.4.</span> <span class="nav-text">java环境 :</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#更改yum源镜像地址"><span class="nav-number">1.5.</span> <span class="nav-text">更改yum源镜像地址</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#ambari-安装"><span class="nav-number">2.</span> <span class="nav-text">ambari 安装</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#httpd服务搭建"><span class="nav-number">2.1.</span> <span class="nav-text">httpd服务搭建</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#搭建本地源：ambari、HDP、HDP-UTILS源、Mysql源"><span class="nav-number">2.2.</span> <span class="nav-text">搭建本地源：ambari、HDP、HDP-UTILS源、Mysql源</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#mysql-本地源环境搭建-mysql-5-7"><span class="nav-number">2.3.</span> <span class="nav-text">mysql 本地源环境搭建 mysql 5.7</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#mysql-主备同步，高可用配置，为防止master节点宕机，在master1、slave1上搭建mysql-主备机实时同步"><span class="nav-number">2.4.</span> <span class="nav-text">mysql 主备同步，高可用配置，为防止master节点宕机，在master1、slave1上搭建mysql,主备机实时同步</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#安装Ambari"><span class="nav-number">2.5.</span> <span class="nav-text">安装Ambari</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#在mysql数据库中创建ambari数据库"><span class="nav-number">2.6.</span> <span class="nav-text">在mysql数据库中创建ambari数据库</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#执行脚本创建ambari数据库"><span class="nav-number">3.</span> <span class="nav-text">执行脚本创建ambari数据库</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#JDBC驱动"><span class="nav-number">4.</span> <span class="nav-text">JDBC驱动</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#setup-ambari"><span class="nav-number">5.</span> <span class="nav-text">setup ambari</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#start-ambari"><span class="nav-number">6.</span> <span class="nav-text">start ambari</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#建立ssh免密登录"><span class="nav-number">7.</span> <span class="nav-text">建立ssh免密登录</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#选择Use-Local-Repository"><span class="nav-number">7.1.</span> <span class="nav-text">选择Use Local Repository</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#选择Target-Hosts"><span class="nav-number">7.2.</span> <span class="nav-text">选择Target Hosts</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#传入rsa私钥-ssh-id-rsa-注意是id-rsa里面的值，而不是公钥"><span class="nav-number">7.3.</span> <span class="nav-text">传入rsa私钥: ~/.ssh/id_rsa(注意是id_rsa里面的值，而不是公钥)</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#启用chronyd"><span class="nav-number">7.4.</span> <span class="nav-text">启用chronyd</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Assign-Slaves-and-Clients"><span class="nav-number">8.</span> <span class="nav-text">Assign Slaves and Clients</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Prerequisites-install"><span class="nav-number">9.</span> <span class="nav-text">Prerequisites install</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Prerequisites-install-1"><span class="nav-number">10.</span> <span class="nav-text">Prerequisites install</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#install-mysql192-168-56-10-master1-bigdata-com-master1"><span class="nav-number">11.</span> <span class="nav-text">install mysql192.168.56.10 master1.bigdata.com master1</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#mysql-repo"><span class="nav-number">12.</span> <span class="nav-text">mysql repo</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#ambari"><span class="nav-number">13.</span> <span class="nav-text">ambari</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#stop-firewalld"><span class="nav-number">14.</span> <span class="nav-text">stop firewalld</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#disable-SELINUX"><span class="nav-number">15.</span> <span class="nav-text">disable SELINUX</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#enable-cash"><span class="nav-number">16.</span> <span class="nav-text">enable cash</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#JAVA-HOME"><span class="nav-number">17.</span> <span class="nav-text">JAVA_HOME</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#mysql-jdbc-driver"><span class="nav-number">18.</span> <span class="nav-text">mysql jdbc driver</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#setup-ambari-1"><span class="nav-number">19.</span> <span class="nav-text">setup ambari</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#start-ambari-1"><span class="nav-number">20.</span> <span class="nav-text">start ambari</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#stop-firewalld-1"><span class="nav-number">21.</span> <span class="nav-text">stop firewalld</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#disable-SELINUX-1"><span class="nav-number">22.</span> <span class="nav-text">disable SELINUX</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#—————–rpm——————–"><span class="nav-number">23.</span> <span class="nav-text">—————–rpm——————–</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#—————–curl——————–"><span class="nav-number">24.</span> <span class="nav-text">—————–curl——————–</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#—————–wget——————–"><span class="nav-number">25.</span> <span class="nav-text">—————–wget——————–</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#—————–pdsh——————–"><span class="nav-number">26.</span> <span class="nav-text">—————–pdsh——————–</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#—————–mysql——————–"><span class="nav-number">27.</span> <span class="nav-text">—————–mysql——————–</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#清除mariadb版本的mysql-libs"><span class="nav-number">28.</span> <span class="nav-text">清除mariadb版本的mysql-libs</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#初始化mysql"><span class="nav-number">29.</span> <span class="nav-text">初始化mysql</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#—————–ambari——————–"><span class="nav-number">30.</span> <span class="nav-text">—————–ambari——————–</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#install-ambari"><span class="nav-number">31.</span> <span class="nav-text">install ambari</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#stop-firewalld-2"><span class="nav-number">32.</span> <span class="nav-text">stop firewalld</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#disable-SELINUX-2"><span class="nav-number">33.</span> <span class="nav-text">disable SELINUX</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#JAVA-HOME-1"><span class="nav-number">34.</span> <span class="nav-text">JAVA_HOME</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#BEGIN-ANSIBLE-JAVA-ENVVAR"><span class="nav-number">35.</span> <span class="nav-text">BEGIN ANSIBLE JAVA ENVVAR</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#hosts"><span class="nav-number">36.</span> <span class="nav-text">hosts</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#mysql-jdbc-driver-1"><span class="nav-number">37.</span> <span class="nav-text">mysql jdbc driver</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#setup-ambari-2"><span class="nav-number">38.</span> <span class="nav-text">setup ambari</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#start-ambari-2"><span class="nav-number">39.</span> <span class="nav-text">start ambari</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#HDP"><span class="nav-number">40.</span> <span class="nav-text">HDP</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#3-Custom-JDK"><span class="nav-number">41.</span> <span class="nav-text">[3] Custom JDK</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#3-Custom-JDK-1"><span class="nav-number">42.</span> <span class="nav-text">[3] Custom JDK</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Configuring-database…"><span class="nav-number">43.</span> <span class="nav-text">Configuring database…</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#7-BDB"><span class="nav-number">44.</span> <span class="nav-text">[7] - BDB</span></a></li></ol></div></div></section></div></aside></div></main><footer id="footer" class="footer"><div class="footer-inner"><div class="copyright">&copy; <span itemprop="copyrightYear"><i>2017</i></span> <span class="with-love"><i class="fa fa-heart"></i> </span><span class="author" itemprop="copyrightHolder"><i>Powered By - Liu PengCheng</i></span></div><div class="copyright"><i>Contact Me&nbsp&nbsp&nbsp|&nbsp&nbsp&nbsp</i> <i><a target="_blank" rel="external" href="https://github.com/timior">https://github.com/timior</a></i></div></div></footer><div class="back-to-top"><i class="fa fa-arrow-up"></i></div></div><script type="text/javascript">"[object Function]"!==Object.prototype.toString.call(window.Promise)&&(window.Promise=null)</script><script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script><script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script><script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script><script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script><script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script><script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script><script type="text/javascript" src="/js/src/utils.js?v=5.1.2"></script><script type="text/javascript" src="/js/src/motion.js?v=5.1.2"></script><script type="text/javascript" src="/js/src/affix.js?v=5.1.2"></script><script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.2"></script><script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.2"></script><script type="text/javascript" src="/js/src/post-details.js?v=5.1.2"></script><script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.2"></script><script type="text/javascript">!function(e,t){var n,c=e.getElementsByTagName(t)[0];"function"!=typeof LivereTower&&((n=e.createElement(t)).src="https://cdn-city.livere.com/js/embed.dist.js",n.async=!0,c.parentNode.insertBefore(n,c))}(document,"script")</script><script type="text/javascript">function proceedsearch(){$("body").append('<div class="search-popup-overlay local-search-pop-overlay"></div>').css("overflow","hidden"),$(".search-popup-overlay").click(onPopupClose),$(".popup").toggle();var t=$("#local-search-input");t.attr("autocapitalize","none"),t.attr("autocorrect","off"),t.focus()}var isfetched=!1,isXml=!0,search_path="search.xml";0===search_path.length?search_path="search.xml":/json$/i.test(search_path)&&(isXml=!1);var path="/"+search_path,onPopupClose=function(t){$(".popup").hide(),$("#local-search-input").val(""),$(".search-result-list").remove(),$("#no-result").remove(),$(".local-search-pop-overlay").remove(),$("body").css("overflow","")},searchFunc=function(t,e,o){"use strict";$("body").append('<div class="search-popup-overlay local-search-pop-overlay"><div id="search-loading-icon"><i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i></div></div>').css("overflow","hidden"),$("#search-loading-icon").css("margin","20% auto 0 auto").css("text-align","center"),$.ajax({url:t,dataType:isXml?"xml":"json",async:!0,success:function(t){isfetched=!0,$(".popup").detach().appendTo(".header-inner");var n=isXml?$("entry",t).map(function(){return{title:$("title",this).text(),content:$("content",this).text(),url:$("url",this).text()}}).get():t,r=document.getElementById(e),s=document.getElementById(o),a=function(){var t=r.value.trim().toLowerCase(),e=t.split(/[\s\-]+/);e.length>1&&e.push(t);var o=[];if(t.length>0&&n.forEach(function(n){var r=!1,s=0,a=0,i=n.title.trim(),c=i.toLowerCase(),l=n.content.trim().replace(/<[^>]+>/g,""),h=l.toLowerCase(),p=decodeURIComponent(n.url),u=[],f=[];if(""!=i&&(e.forEach(function(t){function e(t,e,o){var n=t.length;if(0===n)return[];var r=0,s=[],a=[];for(o||(e=e.toLowerCase(),t=t.toLowerCase());(s=e.indexOf(t,r))>-1;)a.push({position:s,word:t}),r=s+n;return a}u=u.concat(e(t,c,!1)),f=f.concat(e(t,h,!1))}),(u.length>0||f.length>0)&&(r=!0,s=u.length+f.length)),r){[u,f].forEach(function(t){t.sort(function(t,e){return e.position!==t.position?e.position-t.position:t.word.length-e.word.length})});function d(e,o,n,r){for(var s=r[r.length-1],i=s.position,c=s.word,l=[],h=0;i+c.length<=n&&0!=r.length;){c===t&&h++,l.push({position:i,length:c.length});var p=i+c.length;for(r.pop();0!=r.length&&(s=r[r.length-1],i=s.position,c=s.word,p>i);)r.pop()}return a+=h,{hits:l,start:o,end:n,searchTextCount:h}}var g=[];0!=u.length&&g.push(d(0,0,i.length,u));for(var v=[];0!=f.length;){var $=f[f.length-1],C=$.position,m=$.word,x=C-20,w=C+80;x<0&&(x=0),w<C+m.length&&(w=C+m.length),w>l.length&&(w=l.length),v.push(d(0,x,w,f))}v.sort(function(t,e){return t.searchTextCount!==e.searchTextCount?e.searchTextCount-t.searchTextCount:t.hits.length!==e.hits.length?e.hits.length-t.hits.length:t.start-e.start});var y=parseInt("1");y>=0&&(v=v.slice(0,y));function T(t,e){var o="",n=e.start;return e.hits.forEach(function(e){o+=t.substring(n,e.position);var r=e.position+e.length;o+='<b class="search-keyword">'+t.substring(e.position,r)+"</b>",n=r}),o+=t.substring(n,e.end)}var b="";0!=g.length?b+="<li><a href='"+p+"' class='search-result-title'>"+T(i,g[0])+"</a>":b+="<li><a href='"+p+"' class='search-result-title'>"+i+"</a>",v.forEach(function(t){b+="<a href='"+p+'\'><p class="search-result">'+T(l,t)+"...</p></a>"}),b+="</li>",o.push({item:b,searchTextCount:a,hitCount:s,id:o.length})}}),1===e.length&&""===e[0])s.innerHTML='<div id="no-result"><i class="fa fa-search fa-5x" /></div>';else if(0===o.length)s.innerHTML='<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>';else{o.sort(function(t,e){return t.searchTextCount!==e.searchTextCount?e.searchTextCount-t.searchTextCount:t.hitCount!==e.hitCount?e.hitCount-t.hitCount:e.id-t.id});var a='<ul class="search-result-list">';o.forEach(function(t){a+=t.item}),a+="</ul>",s.innerHTML=a}};r.addEventListener("input",a),$(".local-search-pop-overlay").remove(),$("body").css("overflow",""),proceedsearch()}})};$(".popup-trigger").click(function(t){t.stopPropagation(),!1===isfetched?searchFunc(path,"local-search-input","local-search-result"):proceedsearch()}),$(".popup-btn-close").click(onPopupClose),$(".popup").click(function(t){t.stopPropagation()}),$(document).on("keyup",function(t){27===t.which&&$(".search-popup").is(":visible")&&onPopupClose()})</script><script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script><script>AV.initialize("A1wx3DRPE3p5UHgCbNYfsKFY-gzGzoHsz","IWhLul5lBXOXlytBSSG8AWnJ")</script><script>function showTime(e){var t=new AV.Query(e),n=[],o=$(".leancloud_visitors");o.each(function(){n.push($(this).attr("id").trim())}),t.containedIn("url",n),t.find().done(function(e){if(0!==e.length){for(c=0;c<e.length;c++){var t=e[c],i=t.get("url"),s=t.get("time"),l=document.getElementById(i);$(l).find(".leancloud-visitors-count").text(s)}for(var c=0;c<n.length;c++){var i=n[c],l=document.getElementById(i),r=$(l).find(".leancloud-visitors-count");""==r.text()&&r.text(0)}}else o.find(".leancloud-visitors-count").text(0)}).fail(function(e,t){console.log("Error: "+t.code+" "+t.message)})}function addCount(e){var t=$(".leancloud_visitors"),n=t.attr("id").trim(),o=t.attr("data-flag-title").trim(),i=new AV.Query(e);i.equalTo("url",n),i.find({success:function(t){if(t.length>0){var i=t[0];i.fetchWhenSave(!0),i.increment("time"),i.save(null,{success:function(e){$(document.getElementById(n)).find(".leancloud-visitors-count").text(e.get("time"))},error:function(e,t){console.log("Failed to save Visitor num, with error message: "+t.message)}})}else{var s=new e,l=new AV.ACL;l.setPublicReadAccess(!0),l.setPublicWriteAccess(!0),s.setACL(l),s.set("title",o),s.set("url",n),s.set("time",1),s.save(null,{success:function(e){$(document.getElementById(n)).find(".leancloud-visitors-count").text(e.get("time"))},error:function(e,t){console.log("Failed to create")}})}},error:function(e){console.log("Error:"+e.code+" "+e.message)}})}$(function(){var e=AV.Object.extend("Counter");1==$(".leancloud_visitors").length?addCount(e):$(".post-title-link").length>1&&showTime(e)})</script></body></html>